main
Sub Main
	Dim doc
	Set doc = Application.ActiveDocument	
	Dim filename,filepath
	filename = InputBox("filename =?",filename,"0")
	filename= Trim(filename)
	'If filename="" Then Exit Sub
	Dim EnvRoot,CacheFolder
	EnvRoot =GetEnvRoot()
	CacheFolder = EnvRoot & "\cache\xy\"
	filepath = CacheFolder & filename & ".txt"

	if FSO_IsFileExist(filepath) = true then 
		dim freadall
		freadall = FSO_OnReadAll(filepath)
		freadall = trim(freadall)
		'if freadall = "" then exit sub		
		'doc.Preference("DRC") = ppcbDRCOff 
		'doc.Preference("Nudge") = ppcbNudgeOff	
		Application.ExecuteCommand("Global Options")
		OptionsDlg.ActiveTab = "Design"
		OptionsDlg.DesignDlg.OnLineDrc = 3
		OptionsDlg.DesignDlg.Nudge = 2
		OptionsDlg.Cancel.Click()
		
		freadall = replace(freadall,chr(10),"")
		dim result,l_result,i
		dim s,ls,j
		dim item
		result = split(freadall,chr(13))
		l_result = ubound(result)-lbound(result)+1
		'msgbox l_result
		for i=0 to l_result-1
			'msgbox result(i)
			item=trim(result(i))			
			s = split(item,chr(9))
			ls = ubound(s)-lbound(s)+1
			'msgbox ls
			if ls = 3 then
				ref = cstr(trim(s(0)))
				'msgbox ref
				if ref="" then
				else
					x = cdbl(s(1))
					y = cdbl(s(2))
					set compobj = doc.Components(ref)
					if compobj is nothing then
					else
						'msgbox compobj.name
						compobj.move x,y
					end if
					
				end if			
			end if  
		next
	end if
	MsgBox "done"
End Sub

Function GetEnvRoot
	dim EnvRoot 
	Dim ws,varName,regPath
	Set ws = CreateObject("WScript.Shell")
	varName = "PADS_SHORTCUT_ROOT"
	regPath ="HKEY_CURRENT_USER\Software\MyApp\PADS\" & varName
	EnvRoot = ws.RegRead(regPath)
	set ws = nothing
	GetEnvRoot = EnvRoot
End Function

Function FSO_IsFileExist(filepath)
	Dim fso,fw
	Set fso = CreateObject("scripting.filesystemobject")
	FSO_IsFileExist= fso.FileExists(filepath)
	Set fso = Nothing
End Function
Function FSO_OnReadAll(filepath)
	Dim fso,fo
	Set fso = CreateObject("scripting.filesystemobject")
	set fo= fso.OpenTextfile(filepath,1)
	FSO_OnReadAll = fo.readall
	fo.close
	set fo = nothing
	Set fso = Nothing
End Function
